import axiosRequest from "@/api/axios-optimize"

// 判断菜单名称是否存在
export function judgeMenuNameExist(data = {}, config = {
  noShowLoading: true, // 不展示全局加载动画
  preventDuplicateRequestsType: "cancel"
}) {
  return axiosRequest.post(`/xiaobuAdmin/system/menu/judgeMenuNameExist`, data, config)
}

// 判断菜单path是否存在
export function judgePathExist(data = {}, config = {
  noShowLoading: true, // 不展示全局加载动画
  preventDuplicateRequestsType: "cancel"
}) {
  return axiosRequest.post(`/xiaobuAdmin/system/menu/judgePathExist`, data, config)
}

// 获取列表
export function getList(data = {}, config = {
  preventDuplicateRequestsType: "cancel",
  noShowLoading: true // 不展示全局加载动画
}) {
  return axiosRequest.get(`/xiaobuAdmin/system/menu`, { params: data, ...config})
}

// 获取详情
export function getDetailById(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.get(`/xiaobuAdmin/system/menu/${data.id}`, { params: {}, ...config})
}

// 更新
export function updateItem(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.put(`/xiaobuAdmin/system/menu/${data.menuId}`, data, config)
}

// 新增
export function createItem(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.post(`/xiaobuAdmin/system/menu`, data, config)
}

// 删除
export function deleteItem(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.delete(`/xiaobuAdmin/system/menu/${data.id}`, {}, config)
}

// 批量删除
export function batchDeleteItems(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.post(`/xiaobuAdmin/system/menu/batchDelete`, data, config)
}

// 改变状态
export function changeStatus(data = {}, config = {
  preventDuplicateRequestsType: "cancel"
}) {
  return axiosRequest.post(`/xiaobuAdmin/system/menu/changeStatus`, data, config)
}

// 获取菜单树 配置父级菜单
export function getMenuTree(data = {}, config = {
  preventDuplicateRequestsType: "cancel"
}) {
  return axiosRequest.get(`/xiaobuAdmin/system/menu/menuTree`, { params: data, ...config})
}

// 获取所有菜单树
export function getAllMenuTree(data = {}, config = {
  preventDuplicateRequestsType: "cancel"
}) {
  return axiosRequest.get(`/xiaobuAdmin/system/menu/allMenuTree`, { params: data, ...config})
}

// 获取可选的父级菜单的pata
export function getActiveMenuPathList(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.get(`/xiaobuAdmin/system/menu/getActiveMenuPathList`, { params: data, ...config})
}

// 获取非按钮菜单类型的菜单列表
export function getMenuListIgnoreBtnMenu(data = {}, config = {
  preventDuplicateRequestsType: "prevent"
}) {
  return axiosRequest.get("/xiaobuAdmin/system/menu/getMenuListIgnoreBtnMenu", { params: data, ...config})
}